package com.zxw.java基础.日期;

import java.util.Calendar;
import java.util.Date;

/**
 * @projectName: util-cloud
 * @package: com.zxw.java基础.日期
 * @className: Test
 * @author: zhangxuewei
 * @description:
 * @date: 2024/7/10 16:47
 * @version: 1.0
 */
public class Test {

    public static void main(String[] args) throws InterruptedException {
//        Date date = new Date();
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(date);
//        System.out.println(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.DAY_OF_MONTH));



        Date date1 = new Date(); // 第一个日期
        Thread.sleep(1000l);
        Date date2 = new Date(); // 第二个日期

        // 比较方法
         if (date1.before(date2)) {
            System.out.println("date1在date2之qian");
        } else {
            System.out.println("两个日期相同");
        }
    }
}
